LiveUser_Admin
[ class tree: LiveUser_Admin ] [ index: LiveUser_Admin ] [ all elements ]

Source for file UserGroup.php

Documentation is available at UserGroup.php

  1. <?php require_once 'index.php'?>
  2. <h3>UserGroup</h3>
  3. <?php
  4. $currentGroup $admin->perm->getGroups();
  5. if  (empty($currentGroup)) {
  6.     echo 'Run the <b>Group</b> test first<br />';
  7.     exit;
  8. }
  9.  
  10. $currentUser $admin->searchUsers();
  11. if  (empty($currentUser)) {
  12.     echo 'Run the <b>User</b> test first<br />';
  13.     exit;
  14. }
  15. // Add
  16. $users   $admin->searchUsers();
  17. $groups $admin->perm->getGroups();
  18.  
  19. foreach ($groups as $group{
  20.     $rand array_rand($users);
  21.     $result $admin->perm->addUserToGroup(array('perm_user_id' => $users[$rand]['perm_user_id']'group_id' => $group['group_id']));
  22.  
  23.     if ($result === false{
  24.         echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  25.     else {
  26.         echo '<b>' $users[$rand]['name''</b> was added to group <b>' $group['group_id''</b><br />';
  27.     }
  28. }
  29. // Get users from one group
  30. $randGroup array_rand($groups);
  31.  
  32. $params = array(
  33.     'filters' => array(
  34.         'group_id' => $groups[$randGroup]['group_id']
  35.     )
  36. );
  37. $usersGroup $admin->perm->getUsers($params);
  38.  
  39. if ($usersGroup === false{
  40.     echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  41. else {
  42.     echo 'Perm ID\'s of the users in group <b>' $groups[$randGroup]['group_id''</b><br />';
  43.     Var_Dump::display($usersGroup);
  44.     echo '<br />';
  45. }
  46.  
  47. // Remove user from one group
  48. $randGroup array_rand($groups);
  49. $user array_rand($users);
  50.  
  51. $filters = array(
  52.     'group_id' => $groups[$randGroup]['group_id'],
  53.     'perm_user_id' => $users[$user]['perm_user_id']
  54. );
  55. $removed $admin->perm->removeUserFromGroup($filters);
  56.  
  57. if ($removed === false{
  58.     echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  59. else {
  60.     echo '<b>' $users[$user]['name''</b> was removed from group <b>'.$groups[$randGroup]['group_id'].'</b><br />';
  61. }
  62.  
  63. // Remove user from all his groups
  64. $randUser array_rand($users);
  65. $filters = array(
  66.     'perm_user_id' => $users[$randUser]['perm_user_id']
  67. );
  68. $removed $admin->perm->removeUserFromGroup($filters);
  69.  
  70. if ($removed === false{
  71.     echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  72. else {
  73.     echo '<b>' $users[$randUser]['name''</b> was removed from <b>ALL</b> his groups<br />';
  74. }
  75.  
  76. // Get users from all groups
  77. foreach ($groups as $group{
  78.     $params = array(
  79.         'filters' => array(
  80.             'group_id' => $group['group_id']
  81.         )
  82.     );
  83.     $usersGroup $admin->perm->getGroups($params);
  84.  
  85.     if ($usersGroup === false{
  86.         echo '<strong>Error on line: '.__LINE__.' last query: '.$admin->perm->_storage->dbc->last_query.'</strong><br />';
  87.     else {
  88.         echo 'Perm ID\'s of the users in group <b>' $group['group_id''</b><br />';
  89.         Var_Dump::display($usersGroup);
  90.         echo '<br />';
  91.     }
  92. }
  93. echo '<hr />';

Documentation generated on Mon, 11 Mar 2019 14:00:09 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.